It is previously known that heat exchangers can be used for heating hot water. A special problem in this respect is that the supply of hot water from the district heating system must be shut off rapidly when the tapping of hot water is interrupted. Otherwise there is a risk that the water will be overheated, creating among other things the risk of scalding. The document EP 608195 discloses a solution to this problem. A temperature sensor is located in an immersion tube which is in contact with the water in both the district heating and hot water circuits. However, because the sensor is located in water, less favourable detection of water temperature is achieved. This applies especially at lower flows and particularly with stationary water. Another known problem is oscillation of hot water temperature during tapping. This applies especially during changes in tapping flow. The most common reason for this problem is a too slow temperature detection.